<?php
/**
 * Created by PhpStorm.
 * User: dengyun
 * Date: 2017/8/4
 * Time: 13:56
 */

namespace app\api\validate;

use app\api\exception\BannerMissException;
use app\api\exception\ParameterException;
use think\Exception;
use think\Request;
use think\Validate;

class BaseValidate extends Validate
{

    public function goCheck()
    {
        $request = Request::instance();
        $params = $request->param();
        if(!$this->batch()->check($params)){
            throw new ParameterException([
                'msg' => $this->error
            ]);
        } else {
            return true;
        }
    }
    // 必须是正整数
    protected function isPositiveInteger($value, $rule='', $data='', $field='')
    {
        if (is_numeric($value) && is_int($value + 0) && ($value + 0) > 0) {
            return true;
        } else {
            return false;
        }
    }

}